﻿@{
    ViewBag.Title = "文件管理";
    Layout = "~/Views/Shared/_AdminLayout.cshtml";
}

@section Header
{
    <link href="~/assets/plupload/jquery.plupload.queue/css/jquery.plupload.queue.css" rel="stylesheet" />
    <script src="~/assets/plupload/plupload.full.min.js"></script>
    <script src="~/assets/plupload/jquery.plupload.queue/jquery.plupload.queue.min.js"></script>
    <script src="~/assets/plupload/i18n/zh_CN.js"></script>
}

<ol class="breadcrumb">
    <li><a href="@Url.Action("CourseManager","Admin")">课程管理</a></li>
    <li><a href="#">@ViewBag.CourseName</a></li>
    <li>文件管理</li>
</ol>

<div class="col-md-2">
    <div class="list-group">
        <a href="@Url.Action("Course", "Admin", new { cid = ViewBag.CourseId })" class="list-group-item active">课程设置</a>
        <a href="@Url.Action("ClassHour", "Admin", new { cid = ViewBag.CourseId })" class="list-group-item ">课时管理</a>
        <a href="@Url.Action("FileManager", "Admin", new { cid = ViewBag.CourseId })" class="list-group-item ">文件管理</a>
        <a href="#" class="list-group-item ">试题管理</a>
    </div>
</div>

<div class="col-md-10">
    <div class="panel panel-default panel-col">
        <div class="panel-heading">
            <a class="btn btn-info btn-xs pull-right add_course_file">
                <i class="glyphicon glyphicon-cloud-upload"></i>添加课程文件
            </a>
            课程文件
        </div>

        <div class="panel-body" id="file-manage-panel" data-file-status-url="/course/manage/file/status">
            <table class="table table-striped table-hover" id="course-lesson-table">
                <thead>
                    <tr>
                        <th width="5%"><input type="checkbox" data-role="batch-select"></th>
                        <th>文件名</th>
                        <th>类型</th>
                        <th>大小</th>
                        <th>使用</th>
                        <th>最后更新</th>
                    </tr>
                </thead>
                <tbody>

                    @for (int i = 0; i < ViewBag.Files.Count; i++)
                    {
                        var file = ViewBag.Files[i];

                        <tr id="upload-file-tr-18" data-role="item" data-converthash="ch-coursematerial/5/20161008100010-93zhcg.doc">
                            <td><input value="18" type="checkbox" data-role="batch-item"></td>
                            <td>
                                <a href="#" target="_blank" rel="tooltip" title="" data-original-title=" @file.Name ">
                                    @file.Name
                                </a>
                                <br><span class="label label-default tip">未转码</span>
                            </td>
                            <td>
                                @file.DocType
                            </td>
                            <td>  @file.Size </td>
                            <td>
                                <span class="label label-default tip" data-original-title="" title="">@{var used = file.Used ? "已使用" : "未使用";}@used</span>
                            </td>
                            <td>
                                <span class="text-sm">
                                    <a class="link-dark " href="#">admin</a>
                                </span>
                                <br>
                                <span class="text-muted text-sm">
                                    @file.CreateTime
                                </span>
                            </td>
                        </tr>
                    }

                </tbody>
            </table>

            <label class="checkbox-inline mrm mbm"><input type="checkbox" data-role="batch-select"> 全选</label>

            <div class="btn-group mbm">
                <button class="btn btn-danger btn-sm" data-role="batch-delete" data-name="文件记录" data-url="/course/5/manage/show/delete/materials?type=courseLesson">
                    <i class="glyphicon glyphicon-trash"></i>
                    移除
                </button>
            </div>

            <nav class="text-center">

            </nav>

        </div>
    </div>

</div>

<div id="modal" class="modal in">
    <div class="modal-dialog  modal-lg">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
                <h4 class="modal-title">上传文件</h4>
            </div>
            <div class="modal-body">
                <!--文件上传-->
                <form method="post" action="@Url.Action("Upload", "Test")">
                    <div id="uploader">
                        <p>您的浏览器不支持上传插件：Flash、Silverlight或HTML5。</p>
                    </div>
                </form>

                <div class="alert alert-info">
                    <ul>
                        <li>支持<strong>mp4, mp3</strong>格式的文件上传，且文件大小不能超过<strong>2.0GB</strong>。<br>MP4文件的视频编码格式，请使用AVC(H264)编码，否则浏览器无法播放。</li>
                        <li>视频将上传到<strong>网站服务器</strong>，如需使用云视频,点击<a href="#" target="_blank">这里</a>了解详情。</li>
                    </ul>
                </div>

            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-primary" data-dismiss="modal">关闭</button>
            </div>
        </div>
    </div>
</div>

<script type="text/javascript">
    $(function () {

        var uploader = $("#uploader").pluploadQueue({
            // 常规设置
            runtimes: 'html5,flash,silverlight,html4',
            url: '@Url.Action("FileUpload", "Admin")',
            //browse_button: 'btn_browse',
            chunk_size: '4mb',
            rename: true,
            dragdrop: true,
            multiple_queues: true,

            multipart_params: {
                'cid': '@ViewBag.CourseId'
            },

            views: {
                list: true,
                thumbs: true, // Show thumbs
                active: 'thumbs'
            },

            filters: {
                // 最大文件尺寸
                max_file_size: '1024mb',
                // 支持文件类型
                mime_types: [
                    { title: "Image files", extensions: "jpg,gif,png" },
                    { title: "Zip files", extensions: "zip" },
                    { title: "Media files", extensions: "mp4,wmv" }
                ]
            },

            //设置图片：是否裁剪、尺寸和缩放质量
            crop: false,
            resize: { width: 320, height: 240, quality: 90 },

            flash_swf_url: '@Url.Content("~/assets/plupload/Moxie.swf")'
        });

        $(".add_course_file").click(function () {
            $('#modal').modal('show');
        });
    });
</script>